<template>
  <div class="bg">
    <nav-com
      :title="title"
      :showView="true"
      @back="backHandler()"
    ></nav-com>
    <div class="detail">
      <div
        v-if="dataList.length==0"
        class="nodata"
      >--暂无数据--</div>
      <div
        class="data-box"
        v-for="item in dataList"
        :key="item.id"
      >
        <div class="recorde-type">{{item.createtime}}</div>
        <div class="top-info">
          <div>
            <div>
              <div
                class="info"
                v-if="item.type_value=='add'||item.type_value=='exchange'"
              >增加 - {{item.name}}({{item.money}})</div>
              <div
                class="info"
                v-else-if="item.type_value=='reduce'"
              >转增 - {{item.name}}({{item.money}})</div>
              <div
                class="info"
                v-else
              >提货券支付 - 购买{{item.name}}({{item.money}})</div>
            </div>
            <div
              class="num"
              v-if="item.type_value=='reduce'"
            >转给：{{item.mobile}}</div>
            <div
              class="num"
              v-else-if="item.type_value=='add'"
            >来自：{{item.mobile}}</div>
            <div
              class="num"
              v-else-if="item.type_value=='exchange'"
            >来自：{{item.type}}</div>
          </div>
          <div class="money">
            {{item.flag || '-'}}{{item.num || item.sum || 1}}张
          </div>
        </div>
      </div>
    </div>
  </div>

</template>

<script>
import navCom from "@/component/nav";
import { getExaRecorde } from "@/api/api";
export default {
  components: {
    navCom,
  },
  data() {
    return {
      page: 1,
      dataList: [],
      titleList:['提货券总明细', '下单明细'],
      title:''
    };
  },
  created() {
    this.type = this.$route.params.type;
    if(this.type){
      this.title = this.titleList[0]
    }else{
      this.title = this.titleList[1]
    }
    this.initData();
  },
  methods: {
    backHandler() {
      this.$router.go(-1);
    },
    initData() {
      let queryData = {
        offset: this.page,
        limit: 10,
        type: this.type,
      };
      getExaRecorde(queryData)
        .then((res) => {
          if (res.data.code == 1) {
            this.dataList = [...this.dataList, ...res.data.data];
            if (res.data.data.length > 0) {
              this.page += 1;
              this.initData();
            }
          }
        })
        .catch((err) => {});
    },
  },
};
</script>

<style scoped>
.nodata {
  margin-top: 10vh;
  text-align: center;
}
.recorde-type {
  color: #808080;
  margin-bottom: 3vw;
  border-bottom: 1px solid #eee;
}
.bg {
  min-height: 100vh;
  background: #f2f3f7;
}
.detail {
  padding: 3vw 5vw;
}
.data-box {
  background: #fff;
  padding: 2vw 5vw;
  border-radius: 3vw;
  line-height: 26px;
  font-size: 14px;
  margin-bottom: 10px;
}
.top-info {
  line-height: 8vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.top-info .info {
  width: 65vw;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.top-info .money {
  color: #fe4b20;
  font-size: 4vw;
  font-weight: 700;
}
.name {
  font-weight: 700;
  color: #000;
  font-size: 18px;
}
.status {
  float: right;
  color: #02c72b;
  font-weight: 700;
  font-size: 16px;
}
</style>